﻿<!-- #include file="function.asp" -->
<!-- #include file="function_pro.asp" -->
<%
'注册插件
Call Registerplugin("WindsPhoto", "Activeplugin_WindsPhoto")

Dim WP_VERSION,WP_ALBUM_NAME,WP_ALBUM_INTRO,WP_SUB_DOMAIN,WP_SCRIPT_TYPE,WP_ORDER_BY,WP_THUMB_TYPE,WP_SMALL_WIDTH,WP_SMALL_HEIGHT,WP_LIST_WIDTH,WP_WATERFLOW_WIDTH,WP_UPLOAD_DIR,WP_UPLOAD_DIRBY,WP_UPLOAD_RENAME,WP_WATERMARK_WIDTH_POSITION,WP_WATERMARK_HEIGHT_POSITION,WP_JPEG_QUALITY,WP_JPEG_FONTFAMILY,WP_JPEG_FONTCOLOR,WP_JPEG_FONTBOLD,WP_JPEG_FONTITALIC,WP_JPEG_FONTSIZE,WP_JPEG_FONTQUALITY,WP_WATERMARK_AUTO,WP_WATERMARK_TYPE,WP_WATERMARK_TEXT,WP_WATERMARK_LOGO,WP_WATERMARK_ALPHA,WP_INDEX_PAGERCOUNT,WP_SMALL_PAGERCOUNT,WP_LIST_PAGERCOUNT,WP_BLOGPHOTO_ID,WP_IF_ASPJPEG,WP_EXIF_ITEMS,WP_CAMERA_MODEL,WP_JPEG_WIDTH,WP_JPEG_MAXWIDTH

Dim WP_Config
Function WindsPhoto_Initialize()
	Set WP_Config=New TConfig
	WP_Config.Load "WindsPhoto"
	If WP_Config.Exists("WP_VERSION")=False Then
		WP_Config.Write "WP_VERSION","3.1.6"
		WP_Config.Write "WP_ALBUM_NAME","我的相册"
		WP_Config.Write "WP_ALBUM_INTRO","<p>WindsPhoto是基于ASP的Z-Blog图片相册插件，功能强大，简单易用。</p>"
		WP_Config.Write "WP_SUB_DOMAIN",ZC_BLOG_HOST&"zb_users/plugin/windsphoto/"
		WP_Config.Write "WP_SCRIPT_TYPE","3"
		WP_Config.Write "WP_ORDER_BY","1"
		WP_Config.Write "WP_THUMB_TYPE","1"
		WP_Config.Write "WP_SMALL_WIDTH",160
		WP_Config.Write "WP_SMALL_HEIGHT",160
		WP_Config.Write "WP_LIST_WIDTH",600
		WP_Config.Write "WP_WATERFLOW_WIDTH",160
		WP_Config.Write "WP_UPLOAD_DIR","photofile"
		WP_Config.Write "WP_UPLOAD_DIRBY","1"
		WP_Config.Write "WP_UPLOAD_RENAME","True"
		WP_Config.Write "WP_WATERMARK_WIDTH_POSITION","right"
		WP_Config.Write "WP_WATERMARK_HEIGHT_POSITION","bottom"
		WP_Config.Write "WP_JPEG_QUALITY",80
		WP_Config.Write "WP_JPEG_FONTCOLOR","#000"
		WP_Config.Write "WP_JPEG_FONTFAMILY","宋体"
		WP_Config.Write "WP_JPEG_FONTBOLD","True"
		WP_Config.Write "WP_JPEG_FONTITALIC","False"
		WP_Config.Write "WP_JPEG_FONTSIZE","14"
		WP_Config.Write "WP_JPEG_FONTQUALITY","4"
		WP_Config.Write "WP_WATERMARK_AUTO","True"
		WP_Config.Write "WP_WATERMARK_TYPE","1"
		WP_Config.Write "WP_WATERMARK_TEXT","WindsPhoto"
		WP_Config.Write "WP_WATERMARK_LOGO","images/photo_1.png"
		WP_Config.Write "WP_WATERMARK_ALPHA","0.7"
		WP_Config.Write "WP_INDEX_PAGERCOUNT",12
		WP_Config.Write "WP_SMALL_PAGERCOUNT",18
		WP_Config.Write "WP_LIST_PAGERCOUNT",8
		WP_Config.Write "WP_BLOGPHOTO_ID",0
		WP_Config.Write "WP_IF_ASPJPEG","True"
		WP_Config.Write "WP_EXIF_ITEMS",""
		WP_Config.Write "WP_CAMERA_MODEL",""
		WP_Config.Write "WP_JPEG_WIDTH","1280"
		WP_Config.Write "WP_JPEG_MAXWIDTH","True"
	End If
	If WP_Config.Read("WP_VERSION")="2.8" Then
		WP_Config.Write "WP_VERSION","3.0"
		WP_Config.Write "WP_WATERFLOW_WIDTH",160
		WP_Config.Write "WP_UPLOAD_RENAME","True"
		WP_Config.Write "WP_WATERMARK_AUTO","True"
		WP_Config.Write "WP_IF_ASPJPEG","True"
		WP_Config.Remove "WP_LIST_HEIGHT"
		WP_Config.Remove "WP_UPLOAD_FILESIZE"
		Call DelToFile(BlogPath&"/zb_users/plugin/windsphoto/admin_html.asp")
	End If
	If WP_Config.Read("WP_VERSION")<="3.0" Then
		WP_Config.Write "WP_VERSION","3.1.2"
		WP_Config.Write "WP_JPEG_QUALITY",80
		Call DelToFile(BlogPath&"/zb_users/plugin/windsphoto/admin_savephoto.asp")
		Call DelToFile(BlogPath&"/zb_users/plugin/windsphoto/admin_savetype.asp")
		Call DelToFile(BlogPath&"/zb_users/plugin/windsphoto/admin_savesetting.asp")
		Call DelToFile(BlogPath&"/zb_users/plugin/windsphoto/admin_updatecache.asp")
	End If
	If WP_Config.Read("WP_VERSION")<="3.1.2" Then
		WP_Config.Write "WP_VERSION","3.1.3"
		WP_Config.Write "WP_THUMB_TYPE","1"
		WP_Config.Write "WP_JPEG_FONTFAMILY","宋体"
		WP_Config.Write "WP_JPEG_FONTITALIC","False"
	End If
	If WP_Config.Read("WP_VERSION")<="3.1.3" Then
		WP_Config.Write "WP_VERSION","3.1.6"
		WP_Config.Write "WP_EXIF_ITEMS",""
		WP_Config.Write "WP_CAMERA_MODEL",""
		WP_Config.Write "WP_JPEG_WIDTH","1280"
		WP_Config.Write "WP_JPEG_MAXWIDTH","True"
	End If
	WP_Config.Save
	WP_VERSION = WP_Config.Read("WP_VERSION")
	WP_ALBUM_NAME = WP_Config.Read("WP_ALBUM_NAME")
	WP_ALBUM_INTRO = WP_Config.Read("WP_ALBUM_INTRO")
	WP_SUB_DOMAIN =WP_Config.Read("WP_SUB_DOMAIN")
	WP_SCRIPT_TYPE = WP_Config.Read("WP_SCRIPT_TYPE")
	WP_ORDER_BY = WP_Config.Read("WP_ORDER_BY")
	WP_THUMB_TYPE = CInt(WP_Config.Read("WP_THUMB_TYPE"))
	WP_SMALL_WIDTH = CInt(WP_Config.Read("WP_SMALL_WIDTH"))
	WP_SMALL_HEIGHT = CInt(WP_Config.Read("WP_SMALL_HEIGHT"))
	WP_LIST_WIDTH = CInt(WP_Config.Read("WP_LIST_WIDTH"))
	WP_WATERFLOW_WIDTH = CInt(WP_Config.Read("WP_WATERFLOW_WIDTH"))
	WP_UPLOAD_DIR = WP_Config.Read("WP_UPLOAD_DIR")
	WP_UPLOAD_DIRBY = WP_Config.Read("WP_UPLOAD_DIRBY")
	WP_UPLOAD_RENAME = CBool(WP_Config.Read("WP_UPLOAD_RENAME"))
	WP_WATERMARK_WIDTH_POSITION = WP_Config.Read("WP_WATERMARK_WIDTH_POSITION")
	WP_WATERMARK_HEIGHT_POSITION = WP_Config.Read("WP_WATERMARK_HEIGHT_POSITION")
	WP_JPEG_QUALITY = CInt(WP_Config.Read("WP_JPEG_QUALITY"))
	WP_JPEG_FONTFAMILY = WP_Config.Read("WP_JPEG_FONTFAMILY")
	WP_JPEG_FONTCOLOR = WP_Config.Read("WP_JPEG_FONTCOLOR")
	WP_JPEG_FONTBOLD = CBool(WP_Config.Read("WP_JPEG_FONTBOLD"))
	WP_JPEG_FONTITALIC = CBool(WP_Config.Read("WP_JPEG_FONTITALIC"))
	WP_JPEG_FONTSIZE = WP_Config.Read("WP_JPEG_FONTSIZE")
	WP_JPEG_FONTQUALITY = WP_Config.Read("WP_JPEG_FONTQUALITY")
	WP_WATERMARK_AUTO = CBool(WP_Config.Read("WP_WATERMARK_AUTO"))
	WP_WATERMARK_TYPE = WP_Config.Read("WP_WATERMARK_TYPE")
	WP_WATERMARK_TEXT = WP_Config.Read("WP_WATERMARK_TEXT")
	WP_WATERMARK_LOGO = WP_Config.Read("WP_WATERMARK_LOGO")
	WP_WATERMARK_ALPHA = WP_Config.Read("WP_WATERMARK_ALPHA")
	WP_INDEX_PAGERCOUNT = CInt(WP_Config.Read("WP_INDEX_PAGERCOUNT"))
	WP_SMALL_PAGERCOUNT = CInt(WP_Config.Read("WP_SMALL_PAGERCOUNT"))
	WP_LIST_PAGERCOUNT = CInt(WP_Config.Read("WP_LIST_PAGERCOUNT"))
	WP_BLOGPHOTO_ID = CInt(WP_Config.Read("WP_BLOGPHOTO_ID"))
	WP_IF_ASPJPEG = CBool(WP_Config.Read("WP_IF_ASPJPEG"))
	WP_EXIF_ITEMS = WP_Config.Read("WP_EXIF_ITEMS")
	WP_CAMERA_MODEL = WP_Config.Read("WP_CAMERA_MODEL")
	WP_JPEG_WIDTH = CInt(WP_Config.Read("WP_JPEG_WIDTH"))
	WP_JPEG_MAXWIDTH = CBool(WP_Config.Read("WP_JPEG_MAXWIDTH"))
End Function

'安装插件
Function Installplugin_WindsPhoto()
	On Error Resume Next
	Call WindsPhoto_Initialize
	Call WindsPhoto_Add_Navbar()
	Call WindsPhoto_Add_Template()
	Call WindsPhoto_Add_Database()
	Call WindsPhoto_SaveFunctions("wp_photoinfo","图片信息","divWP_Photoinfo","ul","html","<#WP_PHOTOINFO#>")
	Call WindsPhoto_SaveFunctions("wp_photomap","图片位置","divWP_Photomap","div","html","<#WP_PHOTOMAP#>")
	Call WindsPhoto_SaveAlbumlist()
	Call WindsPhoto_SaveNewestlist()
	Call SetBlogHint_Custom("[WindsPhoto]已启用,现在进入相册设置.")
	Response.Redirect BlogHost &"zb_users/plugin/WindsPhoto/admin_setting.asp"
	Err.Clear
End Function

'卸载插件
Function UnInstallplugin_WindsPhoto()
	Call WindsPhoto_Del_Navbar()
	Call WindsPhoto_DelFunctions("wp_photoinfo")
	Call WindsPhoto_DelFunctions("wp_albumlist")
	Call WindsPhoto_DelFunctions("wp_newestlist")
	Call SetBlogHint_Custom("[WindsPhoto]已停用,由本插件生成的侧栏模块已删除,你上传的图片文件以及数据库仍然保留,完全卸载请删除插件.")
End Function

Function Activeplugin_WindsPhoto()
	Call Add_Response_Plugin("Response_Plugin_SettingMng_SubMenu", MakeSubMenu("WindsPhoto设置", BlogHost & "zb_users/plugin/windsphoto/admin_setting.asp", "m-left", False))
	Call Add_Response_Plugin("Response_Plugin_Admin_Left",MakeLeftMenu(2,"相册管理",GetCurrentHost&"zb_users/plugin/windsphoto/admin_main.asp","nav_windsphoto","aWindsPhoto",GetCurrentHost&"zb_users/plugin/windsphoto/images/photo_1.png"))
	'Call Add_Response_Plugin("Response_Plugin_FileMng_SubMenu", MakeSubMenu("WindsPhoto贴图相册管理", BlogHost & "zb_users/plugin/windsphoto/admin_addphoto.asp?typeid="&WP_BLOGPHOTO_ID&"", "m-left", False))
	Call Add_Filter_Plugin("Filter_Plugin_UEditor_Config","WindsPhoto_ExportUEConfig")
	Call Add_Action_Plugin("Action_Plugin_uEditor_FileUpload_Begin","WindsPhoto_uEditorUpload")
	Call Add_Action_Plugin("Action_Plugin_uEditor_imageManager_Begin","WindsPhoto_uEditorAlbumList")
End Function
%>